<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2020/5/10
 * Time: 8:38
 */

namespace app\adminapiv3\service;


class HostExclude extends Base
{
    /**
     * @name 列表
     * @param array $params
     * @param int $limit
     * @return mixed
     * @Author wx
     * @date 2019/8/15 15:23
     */
    function list($hostId, $params = array(), $limit = 30)
    {
        $server = new \app\common\service\HostExclude();
        $data = $server->list($hostId, $params, $limit);

        return $data;
    }

    /**
     * @name 删除
     * @param $id
     * @return bool
     * @Author wx
     * @date 2019/8/15 15:23
     */
    function del($id)
    {
        //重置文件恢复
        $isLock = db('host_exclude')->where('id', $id)->value('is_lock');

        if($isLock != 0){
            db('FileAttack')->where('id', $id)->where('host_id', $isLock)->update(['reset' => 0]);
        }


        //删除
        $condition[] = ['id', 'in', $id];
        $server = new \app\common\service\HostExclude();
        $server->del($condition);

        return true;
    }

    /**
     * @name 添加
     * @param $insertData
     * @return bool
     * @Author wx
     * @date 2019/8/15 15:23
     */
    function add($insertData)
    {
        $insertData['ctime'] = time();

        $server = new \app\common\service\HostExclude();
        $server->add($insertData);

        return true;
    }

    /**
     * @name 修改
     * @param $insertData
     * @return bool
     * @Author wx
     * @date 2019/8/15 15:23
     */
    function modify($id, $updateData)
    {
        $condition = ['id' => $id];
        $server = new \app\common\service\HostExclude();
        $server->modify($condition, $updateData);

        return true;
    }


}